//
//  HomeViewController.m
//  Konditor Meister
//
//  Created by Apple on 19/11/12.
//  Copyright (c) 2012 Apple. All rights reserved.
//

#import "HomeViewController.h"

#define NUMBERCAKES 8

@interface HomeViewController ()

@end

@implementation HomeViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(void)tapimage:(UITapGestureRecognizer *)gesture
{
    FullCakeViewController *controller = [[FullCakeViewController alloc] init];
    controller.currentImage = [gesture.view tag];
    [self.navigationController  pushViewController:controller
                                          animated:YES];
}


- (void)viewDidLoad
{
    NSInteger counter = 0;
    arrayCakes = [[NSMutableArray  alloc] init];
    
    [scrollCakes setContentSize:CGSizeMake(320, NUMBERCAKES/4*70)];
        int incX = 10;
    int incY = 10;
    for(int i=0;i< 4;i++)
    {
        for(int j=0;j<4;j++)
        {
            UIImageView *imageCake = [[UIImageView  alloc] initWithFrame:CGRectMake(incX, incY, 70  , 60)];
            imageCake.userInteractionEnabled = YES;
            imageCake.image = [UIImage imageNamed:[NSString stringWithFormat:@"base%d.png",++counter] ];
            imageCake.tag = counter;
            
            UITapGestureRecognizer *gesture = [[UITapGestureRecognizer  alloc] init];
            [imageCake  addGestureRecognizer:gesture];
            [gesture addTarget:self
                        action:@selector(tapimage:)];
            
            [scrollCakes  addSubview:imageCake];
            incX += 80;
        }
        incX = 10;
        incY += 70;
    }
//    [scrollCakes setContent]
//    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view
//                                              animated:YES];
//    hud.labelText = @"Loading";

    
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
